%load_ext autoreload
%autoreload 2
from scip_workflows.common import *
from aicsimageio import AICSImage
import re
try:
input_file = snakemake.input[0]
output = snakemake.output[0]
except NameError:
input_file = Path("/home/maximl/scratch/data/vsc/datasets/cd7/800/Experiment-800.czi")
output = Path("/home/maximl/scratch/data/vsc/datasets/cd7/800/scenes.txt")
im = AICSImage(input_file, reconstruct_mosaic=False)
pattern = r"P(?P<position>[0-9]+)-(?P<exp>[A-Z])(?P<replicate>[0-9])"
df = pandas.DataFrame(map(lambda a: re.match(pattern, a).groupdict(), im.scenes))
df = df[df["exp"] == "D"]
df["position"] = df["position"].astype(int)
df["replicate"] = df["replicate"].astype(int)
df = df.set_index(["replicate", "position"])
im.set_scene("P1-D1")
fig, ax = plt.subplots(dpi=150)
ax.imshow(numpy.max(im.get_image_data("ZXY", C=5), axis=0), origin="lower", cmap="Greys")
ax.set_axis_off()
def draw_tile(data, channel, color=None, hue=None):
p, rep = data.position.iloc[0], data.replicate.iloc[0]
im.set_scene(f"P{p}-D{rep}")
ax = plt.gca()
ax.imshow(numpy.max(im.get_image_data("ZXY", C=channel), axis=0), origin="lower", cmap="viridis")
ax.set_axis_off()
print(f"{p}-{rep}", end=" ")
# DAPI
grid = seaborn.FacetGrid(data=df.reset_index(), col="position", row="replicate", margin_titles=True)
grid.map_dataframe(draw_tile, channel=0)
for ax in grid.axes.ravel():
ax.set_axis_off()
1-5 2-5 3-5 4-5 5-5 6-5 7-5 8-5 9-5 10-5 11-5 12-5 13-5 14-5 15-5 16-5 17-5 18-5 19-5 20-5 21-5 22-5 23-5 24-5 25-5 1-4 2-4 3-4 4-4 5-4 6-4 7-4 8-4 9-4 10-4 11-4 12-4 13-4 14-4 15-4 16-4 17-4 18-4 19-4 20-4 21-4 22-4 23-4 24-4 25-4 1-3 2-3 3-3 4-3 5-3 6-3 7-3 8-3 9-3 10-3 11-3 12-3 13-3 14-3 15-3 16-3 17-3 18-3 19-3 20-3 21-3 22-3 23-3 24-3 25-3 1-2 2-2 3-2 4-2 5-2 6-2 7-2 8-2 9-2 10-2 11-2 12-2 13-2 14-2 15-2 16-2 17-2 18-2 19-2 20-2 21-2 22-2 23-2 24-2 25-2 1-1 2-1 3-1 4-1 5-1 6-1 7-1 8-1 9-1 10-1 11-1 12-1 13-1 14-1 15-1 16-1 17-1 18-1 19-1 20-1 21-1 22-1 23-1 24-1 25-1